<?php
session_start();
/* 
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))
{
	ob_start('ob_gzhandler');

	$cachedir = 'caching/'; 
	$cachetime = 3600;  
	$cacheext = 'caching'; 
	$page ='http://'. $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
	$pathfile = $cachedir . md5($page) . '.' . $cacheext; 
	$file_created =(file_exists($pathfile)==true)? filemtime($pathfile):0;
	
	ob_start('ob_gzhandler');
	if (time() - $cachetime < $file_created)
	{
	    readfile($pathfile);       
	    ob_end_flush();
	    exit();
	}
	
	


}else
{ 

	ob_start();

} 
 */
header('Content-type: text/html; charset=utf-8');
//error_reporting(E_ALL);
//ini_set('display_errors','On');
include_once('config.php');
include_once(path_lib.'khithe.database.php');
include_once($path.'/applications/bootstrap.php');

if(isset($_REQUEST['kt']))
$route = (empty($_REQUEST['kt'])) ? '' : $_REQUEST['kt'];

define('Route',$route,true);

$parts = explode('/', $route);
if($parts[0]=='')
{ 
	$path_com_systems=path_app.dir_publics.'/com_systems/';
	$file_temp = $path.'/templates/'.dir_publics.'/defaults/';
	$file_lang = $path.'/languages/'.dir_publics.'/'.dir_lang.'/systems.php';
	$file_controller = $path_com_systems.'systems_controller.php';
	$file_model = $path_com_systems.'systems_model.php';
	
}else{	
	/* auto app publics || admin || .v.v. */
	$path_com_systems=path_app.$parts[0].'/com_systems/';
	$file_temp = $path.'/templates/'.$parts[0].'/defaults/';
	$file_lang = $path.'/languages/'.$parts[0].'/'.dir_lang.'/systems.php';
	$file_controller = $path_com_systems.'systems_controller.php';
	$file_model = $path_com_systems.'systems_model.php';	
}

if(!is_file($file_controller))
	echo "Not find app <br /> &raquo; Not find controller";
else if(!is_file($file_model))
	echo "Not find app <br /> &raquo; Not find model";
else if(!is_file($file_lang))
	echo "Not find app <br /> &raquo; Not find lang";
else {
		define("path_temp",$file_temp,true);
		include_once($file_lang);
		include_once($file_model);
		include_once($file_controller);
		$controller = 'systems_controller';
		$model = 'systems_model';
		$ojb_controller = new $controller();

}



/* $cachedir = 'caching/'; 
$cacheext = 'caching'; 
$page = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
$pathfile = $cachedir . md5($page) . '.' . $cacheext; 

$fp = fopen($pathfile, 'w'); 
fwrite($fp, ob_get_contents());
fclose($fp);  

ob_end_flush();*/

